﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ionic.Zip;
using System.Web;
using System.IO;

namespace BL
{
   public  class FileForZip
    {
       public string name{get;set;}
       public string physicalPath { get; set; }
       public string extension { get; set; }

       public static bool MakeZipArchive(List<FileForZip> ffz, string pathToSave)
       {
          // FileForZip createdZip = new FileForZip();
         
           //string ZipFileToCreate = @"F:\Projects\TestZip\TestZipOOO.zip";
           //string[] FileToZip = new string[] { @"F:\1.rar", @"F:\tester_cources_2013\презентации\Dev_cycle.ppt" };
           


           using (ZipFile zip = new ZipFile(Encoding.UTF8))
           {

               foreach (FileForZip files in ffz)
               {
                   var zipped = zip.AddFile(files.physicalPath).FileName = files.name;           
                       //files.physicalPath, files.name);
                
                //   var zipped = zip.AddFile(files.physicalPath, files.name);
                    //@"myfailik\s").FileName = @"myfailik\" + Path.GetFileName(str) + "jorik.exe";

               }

                //Сохраненяем Zip архив
                zip.Save(pathToSave);
           }


           return true;
      
       
       }


    }

}
